#pragma GCC optimize(2, "Ofast", "inline")
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <algorithm>
#define endl '\n'
#define int long long
#define pii pair<int, int>
using namespace std;

// 已知
int n, k, a, b;
// 未知
int s = 0;
signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> k;
    s += k;
    while (n--)
    {
        cin >> a >> b;
        if (a <= s) s += b;
        else break;
    }
    cout << s;
    return 0;
}